package com.zimin.cloud.wiki.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zimin.cloud.mine.pojo.wiki.business.DocBO;
import com.zimin.cloud.mine.pojo.wiki.view.DocVO;
import com.zimin.cloud.wiki.biz.IDocBiz;
import com.zimin.cloud.wiki.controller.api.IDocController;
import com.zimin.shared.pojo.BaseController;
import com.zimin.shared.pojo.PageVO;
import com.zimin.shared.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 文档 前端控制器
 * </p>
 *
 * @author zimin
 * @since 2021-10-27 21:02
 */
@Slf4j
@RestController
public class DocController extends BaseController implements IDocController {


    @Autowired
    private IDocBiz docBiz;

    @Override
    public Result docList(Page page, DocBO docBO) {
        PageVO<DocVO> docVOList = docBiz.list(page, docBO);
        return Result.ok(docVOList);
    }

    @Override
    public Result saveDoc(DocBO docBO) {
        return result(docBiz.save(docBO));
    }

    @Override
    public Result updateDoc(DocBO docBO) {
        return result(docBiz.updateById(docBO));
    }

    @Override
    public Result removeById(String ids) {
        return result(docBiz.removeByIds(ids));
    }

    @Override
    public Result docAll(DocBO docBO) {
        List<DocVO> docVOList = docBiz.allTree(docBO);
        return Result.ok(docVOList);
    }

    @Override
    public Result getDocById(String id) {
        return Result.ok(docBiz.getDocById(id));
    }

}
